<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>促销商品管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		function changetype(type){
			if(type == "904"){
				$("#participateStartDateGroup").css('display','none'); 
				$("#participateEndDateGroup").css('display','none');
				
				$("#barginLimitGroup").css('display','none');
				$("#barginFloorPriceGroup").css('display','none');
				$("#barginFloorPriceForShowGroup").css('display','none');
				$("#barginDurationLimitGroup").css('display','none');
			}else if(type == "905"){
				$("#participateStartDateGroup").css('display','block'); 
				$("#participateEndDateGroup").css('display','block');
				
				$("#barginLimitGroup").css('display','none');
				$("#barginFloorPriceGroup").css('display','none');
				$("#barginFloorPriceForShowGroup").css('display','none');
				$("#barginDurationLimitGroup").css('display','none');
				
			}if(type == "906"){
				$("#participateStartDateGroup").css('display','none'); 
				$("#participateEndDateGroup").css('display','none');
				
				$("#barginLimitGroup").css('display','block');
				$("#barginFloorPriceGroup").css('display','block');
				$("#barginFloorPriceForShowGroup").css('display','block');
				$("#barginDurationLimitGroup").css('display','block');
			}
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/market/sale/form?id=${sale.id}">促销活动<shiro:hasPermission name="market:sale:edit">${not empty sale.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="market:sale:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="sale" action="${ctx}/market/sale/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<!-- <div class="control-group">
			<label class="control-label">event_id：</label>
			<div class="controls">
				<form:input path="event.id" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		 -->
		<div class="control-group">
			<label class="control-label">商品类型：</label>
			<div class="controls">
				<%-- <form:input path="productType" htmlEscape="false" maxlength="3" class="input-xlarge required" /> --%>
				<form:radiobuttons path="productType" items="${fns:getDictList('sale_type')}" onchange="changetype(this.value);"
				itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">活动名称：</label>
			<div class="controls">
				<form:input path="title" htmlEscape="false" maxlength="200" class="input-xlarge required" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>

		<div class="control-group">
			<label class="control-label">原价：</label>
			<div class="controls">
				<form:input path="marketPriceForShow" htmlEscape="false" class="input-xlarge  number required" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">促销价：</label>
			<div class="controls">
				<form:input path="salePrice" htmlEscape="false" class="input-xlarge  number required"  />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">封面图片：</label>
			<div class="controls">
				<form:hidden id="cover" path="cover" htmlEscape="false" maxlength="200" class="input-xlarge required"  />
				<sys:ckfinder input="cover" type="files" uploadPath="/hqhsc" selectMultiple="true"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		
				<div class="control-group">
			<label class="control-label">开始日期：</label>
			<div class="controls">
				<input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${sale.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">截止日期：</label>
			<div class="controls">
				<input name="endDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
					value="<fmt:formatDate value="${sale.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">可购数量：</label>
			<div class="controls">
				<form:input path="buyLimit" htmlEscape="false" maxlength="11" value="1" class="input-xlarge  digits required" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
<%-- 		<div class="control-group"  style="display:none;">
			<label class="control-label">buy_limit_per_day：</label>
			<div class="controls">
				<form:input path="buyLimitPerDay" htmlEscape="false" maxlength="11" class="input-xlarge  digits" />
			</div>
		</div>
		<div class="control-group"  style="display:none;">
			<label class="control-label">participate_limit：</label>
			<div class="controls">
				<form:input path="participateLimit" htmlEscape="false" maxlength="11" class="input-xlarge  digits"/>
			</div>
		</div>
		<div class="control-group"  style="display:none;">
			<label class="control-label">participate_limit_per_day：</label>
			<div class="controls">
				<form:input path="participateLimitPerDay" htmlEscape="false" maxlength="11" class="input-xlarge  digits"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label">运费：</label>
			<div class="controls">
				<form:input path="tranportFee" htmlEscape="false" value="0" class="input-xlarge  number required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
<%-- 		<div class="control-group"  style="display:none;">
			<label class="control-label">covers：</label>
			<div class="controls">
				<form:hidden id="covers" path="covers" htmlEscape="false" maxlength="1000" class="input-xlarge"/>
				<sys:ckfinder input="covers" type="files" uploadPath="/market/sale" selectMultiple="true"/>
			</div>
		</div> --%>
		<div class="control-group"  style="display:none;"  id="barginLimitGroup">
			<label class="control-label">砍价次数：</label>
			<div class="controls">
				<form:input path="barginLimit" htmlEscape="false" maxlength="11" class="input-xlarge  digits"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group"  style="display:none;" id="barginFloorPriceGroup">
			<label class="control-label">真实的底价：</label>
			<div class="controls">
				<form:input path="barginFloorPrice" htmlEscape="false" class="input-xlarge  number"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group"  style="display:none;"  id="barginFloorPriceForShowGroup">
			<label class="control-label">展示的底价：</label>
			<div class="controls">
				<form:input path="barginFloorPriceForShow" htmlEscape="false" class="input-xlarge  number"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group"  style="display:none;" id="barginCeilPriceGroup">
			<label class="control-label">bargin_ceil_price：</label>
			<div class="controls">
				<form:input path="barginCeilPrice" htmlEscape="false" class="input-xlarge  number"/>
			</div>
		</div>
		<div class="control-group"  style="display:none;" id="barginDurationLimitGroup">
			<label class="control-label">时间限制(天)：</label>
			<div class="controls">
				<form:input path="barginDurationLimit" htmlEscape="false" maxlength="11" class="input-xlarge  digits"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>

		<div class="control-group"  style="display:none;" id="participateStartDateGroup">
			<label class="control-label">使用开始时间：</label>
			<div class="controls">
				<input name="participateStartDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${sale.participateStartDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group"  style="display:none;"  id="participateEndDateGroup">
			<label class="control-label">使用截止时间：</label>
			<div class="controls">
				<input name="participateEndDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${sale.participateEndDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">活动描述：</label>
			<div class="controls">
				<form:textarea path="description" htmlEscape="false" rows="4" maxlength="200" class="input-xxlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">商品描述</label>
			<div class="controls">
				<%-- <form:input path="productDescription" htmlEscape="false" class="input-xlarge "/> --%>
				<form:textarea id="productDescription" htmlEscape="true" path="productDescription" rows="4" maxlength="200" class="input-xxlarge required" />
				<sys:ckeditor replace="productDescription" uploadPath="/market/sale" />
			</div>
		</div>
		
		<div class="control-group"  style="display:none;">
			<label class="control-label">share_title：</label>
			<div class="controls">
				<form:input path="shareTitle" htmlEscape="false" maxlength="200" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group"  style="display:none;">
			<label class="control-label">share_content：</label>
			<div class="controls">
				<form:input path="shareContent" htmlEscape="false" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group"  style="display:none;">
			<label class="control-label">share_image：</label>
			<div class="controls">
				<form:input path="shareImage" htmlEscape="false" maxlength="200" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group"  style="display:none;">
			<label class="control-label">share_url：</label>
			<div class="controls">
				<form:input path="shareUrl" htmlEscape="false" maxlength="200" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group"  style="display:none;">
			<label class="control-label">remarks：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="200" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="market:sale:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>